var IDUtenteCorrente="";
var LivelloUtenteCorrente="";

function CheckLogin() {
	
	var user = document.getElementById("username").value;
	var pass = document.getElementById("password").value;
	var logincheck=GetSQLValue("select count(*) as numero from utenti where username='"+user+"' and password='"+pass+"'");
	IDUtenteCorrente=GetSQLValue("select id_utente from utenti where username='"+user+"' and password='"+pass+"'");
	LivelloUtenteCorrente=GetSQLValue("select livello from utenti where id_utente=" + IDUtenteCorrente);

	//alert(logincheck);
	if (logincheck != "1") {
		ConfirmBox("Login Errata!","Login",200,100,"LoginBox()");
		document.getElementById("bottoni_div").removeChild(document.getElementById("CancelButton"));
		//LoginBox();
	} else {
		
		CloseMsgBox();
		PostLoad();
	}
}


function LoginBox() {

	document.getElementById("bordo_traslucito").style.visibility = "visible";
	document.getElementById("bordo_finestra_msgbox").style.visibility = "visible";
	//document.getElementById("msgbox_div").style.filter="alpha(opacity:10)";
	document.getElementById("msgbox_div").style.visibility = "visible";
	document.getElementById("msgbox_div").className = "NoDrag";
	document.getElementById("bordo_finestra_msgbox").style.width = 200;
	document.getElementById("bordo_finestra_msgbox").style.height = 100;
	
	
	document.getElementById("messaggio_div").innerHTML = "<br>Username: <input type=text id=username ><br>Password: <input type=password id=password><br>";
	//updateContent("messaggio_div","<br>Username: <input type=text id=username value='username'><br>Password: <input type=text id=password><br>");

	document.getElementById("titolo_div").innerHTML = "Login";
	document.getElementById("bottoni_div").innerHTML = "";
	
			var oButton = document.createElement("img");
			oButton.src="images/Ok.gif";
			oButton.onclick=CheckLogin;	
			document.getElementById("bottoni_div").appendChild(oButton);	
}